import Mockjs from 'mockjs'
import qs from 'qs'

Mockjs.setup({
  // 模拟请求后台时的延迟
  timeout: '300-500'
})

Mockjs.mock(/\/member\/collect/, 'get', (config) => {
  const queryobj = qs.parse(config.url.split('?')[1])
  const items = []
  for (let i = 0; i < +queryobj.pageSize; i++) {
    items.push(
      Mockjs.mock({
        id: '@id',
        name: '@ctitle(10,20)',
        desc: '@ctitle(4,10)',
        price: '@float(100,200,2,2)',
        picture: `http://zhoushugang.gitee.io/erabbit-client-pc-static/uploads/clothes_goods_${Mockjs.mock(
          '@integer(1,8)'
        )}.jpg`
      })
    )
  }
  return {
    msg: '模拟数据成功',
    result: {
      counts: 35,
      pageSize: +queryobj.pageSize,
      page: +queryobj.page,
      items
    }
  }
})
